package com.weishu.house.controller;


import com.weishu.common.core.utils.SecurityUtils;
import com.weishu.common.core.web.controller.BaseController;
import com.weishu.common.core.web.domain.AjaxResult;
import com.weishu.common.core.web.page.TableDataInfo;
import com.weishu.common.log.annotation.Log;
import com.weishu.common.log.enums.BusinessType;
import com.weishu.common.security.annotation.PreAuthorize;
import com.weishu.house.entity.HouseStyle;
import com.weishu.house.entity.RoomInfo;
import com.weishu.house.service.IHouseStyleService;
import com.weishu.house.service.IRoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 集中式房源-房型信息表 前端控制器
 * </p>
 *
 * @author gao
 * @since 2021-05-25
 */
@RestController
@RequestMapping("/house-style")
public class HouseStyleController extends BaseController {

    @Autowired
    private IHouseStyleService iHouseStyleService;

    @Autowired
    private IRoomInfoService iRoomInfoService;

    @RequestMapping("list")
    public TableDataInfo list(HouseStyle houseStyle){
        startPage();

        List<RoomInfo> list = iHouseStyleService.houseStyle(houseStyle);
        return getDataTable(list);
    }


    /*@PostMapping("add")
    public AjaxResult add(@Validated @RequestBody HouseStyle houseStyle)
    {
        houseStyle.setCreateBy(SecurityUtils.getUsername());
        return toAjax(iHouseStyleService.insertDictData(houseStyle));
    }*/
/*
* 集中式房源添加
* */
    @PostMapping("addddddd")
    public boolean addddddd(@RequestBody HouseStyle houseStyle){
        System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        System.out.println(houseStyle);
        return iHouseStyleService.saveOrUpdate(houseStyle);
    }

    @PostMapping("addd")
    public boolean addd(@RequestBody HouseStyle houseStyle){
        System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
        System.out.println(houseStyle);
        iRoomInfoService.roomInfosava(houseStyle);
        return iHouseStyleService.addd(houseStyle);
    }

}
